<template>
  <div>
    <h1>加加减减</h1>
    <ul>
      <li v-for="(item, index) in arr1" :key="index">
        {{ item }}
        <button @click="fn1(index)">删除</button>
      </li>
    </ul>
    <button @click="fn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr1: [1, 5],
    };
  },
  methods: {
    fn() {
      this.arr1.push(Math.floor(Math.random() * 20 + 1));
    },
    fn1(a) {
      this.arr1.splice(a, 1);
    },
  },
};
</script>

<style scoped>
li {
  display: flex;
}
button {
  margin-left: 20px;
}
</style>
